fix(express): forward all auth options to authenticateRequest#8370
fix(express): forward all auth options to authenticateRequest#8370jacekradko wants to merge 7 commits intomainfrom
Conversation
Spread the full options object through to clerkClient.authenticateRequest() instead of re-destructuring a hand-picked subset. This closes the class of bug where fields accepted by the ClerkMiddlewareOptions type (e.g. organizationSyncOptions, skipJwksCache, headerType) were silently ignored at runtime — same shape as the clockSkewInMs issue fixed in #8287. Middleware-only keys (clerkClient, debug, frontendApiProxy) are peeled off so they don't leak into the backend call.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
🦋 Changeset detectedLatest commit: 14375e0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
… are set The backend's createAuthenticateRequest factory pins apiUrl/apiVersion at client construction time and overrides any runtime values. The Express default ClerkClient singleton is built from env only, so passing apiUrl or apiVersion to clerkMiddleware() was silently ignored on the default path even after option-forwarding was generalized. When the caller hasn't supplied a custom clerkClient but did pass apiUrl or apiVersion, build a per-middleware ClerkClient with those values instead of using the singleton.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR updates Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
…verride Adds two regression tests: - The per-middleware ClerkClient actually routes outbound API traffic to the apiUrl override, not just that createClerkClient was called with it. Spies on global fetch and asserts the URL hits the override host. - The clerkMiddleware callback form (options as a function) also builds a per-middleware ClerkClient when the callback returns apiUrl.
Follow-up to #8287. The middleware was forwarding only a hand-picked subset of options to authenticateRequest, so things like organizationSyncOptions, headerType, and skipJwksCache were typed but silently dropped. Now everything spreads through, minus the middleware-only keys.
apiUrl and apiVersion needed separate handling because @clerk/backend pins them at client construction time and the default Express client is built from env only. When they're set on the middleware and no custom clerkClient is supplied, we now build a per-middleware ClerkClient with those values.